/*
 * js正则表达式修饰符:
 * i :执行对大小写不敏感的匹配.
 * g :执行全局匹配（查找所有匹配而非在找到第一个匹配后停止）
 * m :执行多行匹配。
 * y :只匹配一次（粘连模式）
 * u :unicode模式大于两个字节长度的字符
 */
{
	let regex = new RegExp("xyz", "i");
	let regex2 = new RegExp(/xyz/i);

	console.log(regex.test("xyz123"), regex2.test("xyz123"));

	let regex3 = new RegExp(/xyz/gi, "i");
	console.log(regex3.flags);
}

{
	let s = "bbbb_bb_b";
	let a1 = /b+/g;
	let a2 = /b+/y;

	console.log("one", a1.exec(s), a2.exec(s));
	console.log("two", a1.exec(s), a2.exec(s));
	console.log(a1.sticky, a2.sticky);
}

{
	console.log("u-1", /^\uD83D/.test("\uD83D\uDC2A"));
	console.log("u-1", /^\uD83D/u.test("\uD83D\uDC2A"));

	console.log(/\u{61}/.test("a"));
	console.log(/\u{61}/u.test("a"));
	//unicode编码4个字节一个字符
	console.log("\u{20BB7}");
	let s = "𠮷";
	console.log("u", /^.$/.test(s));
	console.log("u-2", /^.$/u.test(s));

	console.log("test", /𠮷{2}/.test("𠮷𠮷"));
	console.log("test-2", /𠮷{2}/u.test("𠮷𠮷"));
}

{
	let str = "string";
	console.log('includes', str.includes("r"));
	console.log('starWirh', str.startsWith('str'));
	console.log('endWith', str.endsWith('ng'));
}

{
	let str = "abc";
	console.log(str.repeat(2));
}

{
	let name = "list";
	let info = "HelloWorld";
	let template = `i am ${name},${info}`;
	console.log(template);
}

//谷歌浏览器支持这两个函数
{
	console.log('1'.padStart(2,'0'));
	console.log('1'.padEnd(2,'0'));
}

{
	let user = {
		name:'list',
		info:'hello world'
	};
	console.log(abc`i am ${user.name},${user.info}`); 
	function abc(s,v1,v2){
		console.log(s,v1,v2);
		return s+v1+v2;
	}
}

{
	console.log(String.raw`Hi\n${1+2}`);
	console.log(`Hi\n${1+2}`);
}